package com.hst.web.base.proxy;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.hst.core.Page;
import com.hst.core.ServiceContext;
import com.hst.core.dao.IORDao;
import com.hst.core.dao.ISQLDao;
import com.hst.core.dao.ORQuery;
import com.hst.core.dao.ORQuery.Op;
import com.hst.core.meta.MetaData;
import com.hst.core.meta.proxies.DefaultDataProxy;
import com.hst.web.auth.po.User;
import com.hst.web.base.entity.TAccountIdentity;
import com.hst.web.base.entity.TCompanyEmployee;
import com.hst.web.base.entity.TCompanyInfo;
import com.hst.web.base.entity.TContractorInfo;
import com.hst.web.base.entity.TDeptEmployee;
import com.hst.web.base.entity.TEmployeeContractorDept;
import com.hst.web.base.entity.TEmployeeOperate;
import com.hst.web.base.service.UserRoleService;
import com.hst.web.base.ui.ContractorEmployee;
import com.hst.web.base.ui.EmployeeIdentify;
import com.hst.web.common.utils.ConstantUtil;
import com.hst.web.common.utils.DateTimeUtil;
import com.hst.web.common.utils.PapersNumberUtils;

public class ContractorEmployeeYckProxy extends DefaultDataProxy {

	private static final String PUSHFLAG_NOT = "0";

	/**
	 * 人员操作状态：离职
	 */
	private static final String OPTYPE_DEPART = "2";

	@Autowired
	IORDao dao;

	@Autowired
	ISQLDao sql;

	@SuppressWarnings("unchecked")
	@Override
	public Page<?> list(Map<String, ?> query, int pageIdx) {
		UserRoleService.addContractorEmpParam((Map<String, Object>) query);
		
		String currMonth = DateTimeUtil.getCurrMonth();
		Date baseYearLastDate = DateTimeUtil.getCurrYearLast();
		if ("11".equals(currMonth) || "12".equals(currMonth)) {
			baseYearLastDate = DateTimeUtil.getNextYearLast();
		} else if ("1".equals(currMonth) || "2".equals(currMonth) || "3".equals(currMonth)) {
			baseYearLastDate = DateTimeUtil.getCurrYearLast();
		} else {
			baseYearLastDate = DateTimeUtil.getCurrYearLast();
		}
		Map<String,Object> queryMap = (Map<String, Object>) query;
		queryMap.put("endExpirydate", DateTimeUtil.dateToString(baseYearLastDate, "yyyy-MM-dd"));
		
		return sql.list("employee.list-contractor-employee-yck", queryMap, pageIdx, Page.getPageSize());
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<?> list(Map<String, ?> query) {
		UserRoleService.addContractorEmpParam((Map<String, Object>) query);
		return sql.query("employee.list-contractor-employee-yck", query);
	}

}
